<template>
	<view>
		<view v-if="isLoading" style="width: 100%;height: calc(100vh);position: absolute;z-index: 10000;">
			<image src="../../../static/icon/loading.png" style="width: 110rpx;height: 110rpx;" class="loading" mode=""></image>
		</view>
		<view @click="close()" v-if="isShow" style="width: 100%;height: calc(100vh);position: absolute;z-index: 98;"></view>
		<view class="TC" style="position: relative; z-index: 999;" v-if="isShow">
			<view class="box">

				<view class="box1">
					<view class="box1-a">
						<view style="font-size: 40rpx;
		color: #a485ed;">
							提示
						</view>
						<view style="font-size: 40rpx;
		color: #a485ed;width: 100%;
    text-align: center;">
							{{msg}}
							<!-- 图片代替 -->
							<!-- <image 
								src="../../../static/icon/视频.jpg" alt=""> -->
							<!-- 视频 -->

						</view>

						<view class="btnA">
							<button type="button" style="color: #FFFFFF; " @click="close()">确认</button>
						</view>
					</view>

				</view>
			</view>
		</view>

		<view class="mack-a" :style=" 'filter: blur('+this.$store.state.mackNum2+'px);'">
			<view class="box">
				<Back></Back>
				<view class="address">
					<view>
						<image style="width: 81rpx;height: 41rpx;" src="../../../static/icon/gameicon/rightjt.png"
							mode="">
						</image>
					</view>
					<view class="sh">
						<view style="margin-right: 36rpx;font-size: 16px;color: rgb(112,112,112);">收货人：</view>
						<input v-model="dataFrom.full_name" type="text" placeholder="收货人姓名" />
					</view>
					<view class="sh1">
						<view style="margin-right: 36rpx;font-size: 16px;color: rgb(112,112,112);">手机号：</view>
						<input type="number" v-model="dataFrom.mobile" placeholder="请输入手机号" @input="iponeinput" />
					</view>
					<view class="sh2">
						<view style="width: 166rpx;    margin-top: 18rpx; font-size: 16px;color: rgb(112,112,112);">
							详细地址：</view>
						<textarea placeholder="多行输入" v-model="dataFrom.address" name="" id="" cols="30" @input="queren"
							rows="10"></textarea>
					</view>
					<button @click="address()">保 存</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapMutations,mapState
	} from 'vuex'
	import uniRequest from '@/until/uni-request.js'
	import Back from '../../../components/BackPage.vue'
	export default {
		computed: {//加载数据过程loading
			    ...mapState(["isLoading"])
			},
		components: {
			Back
		},
		data() {
			return {
				msg:'',
				isShow: false,
				isBC:false,
				issend:false,
				dataFrom: {
					full_name: "",
					mobile: "",
					address: ""
				}
			}
		},
		onShow() {
			this.close()
		},
		
		methods: {
			iponeinput(){
				
				var strTemp = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
				if(strTemp.test(this.dataFrom.mobile)){
					// uni.showToast({icon:'none',title:'电话格式正确'});
					this.issend=true
					return
				}else{
					uni.showToast({icon:'none',title:'请输入正确的电话'});
					this.issend=false
					return false
				}
			},
			queren(){
				const reg = /\d{8,}/
				console.log();
			if(this.dataFrom.address.length>=8){
				this.isBC=true
				// uni.showToast({icon:'none',title:''});
				// uni.showToast({icon:'none',title:'详细地址请输入8个字以上'});
				// uni.showToast({icon:'none',title:'详细地址可保存'});
				return
			}else{
				uni.showToast({icon:'none',title:'详细地址请输入8个字以上'});
				this.isBC=false
				return false
			}
			},
			...mapMutations(['closemackNum','openTCxun', 'closeTCxun']),
			close() {
				this.isShow = false
				this.closeTCxun()
			},
			address() {
				console.log(this.isBC);
				console.log(this.issend);
				if(this.isBC&&this.issend){
					uniRequest.post('lotteryaddress/lotteryaddress/add', this.dataFrom).then((res) => {
							console.log(res);
							if (res.data.code == "0000") {
								uni.navigateTo({
									url: '/pages/Mypage/IsAddress/IsAddress'
								});
								this.dataFrom.address = '';
								this.dataFrom.full_name = '';
								this.dataFrom.mobile = ''
							}
							if (res.data.code == "1001") {
								this.msg=res.data.msg
								this.isShow=true
								this.openTCxun()
							}
							
						}).catch((err) => {
							console.log(err);
						});
					}
					else{
						if(!this.isBC){
							uni.showToast({icon:'none',title:'详细地址请输入8个字以上'});
							return
						}
						if(!this.issend){
							uni.showToast({icon:'none',title:'请输入正确的电话'});
							return
						}
					}
				}

		},
		
	}
</script>

<style lang="scss" scoped>
	@-webkit-keyframes tdtc {
		0% {
			transform: scale(0.8); 
			// transform: scale(0.8);  
			opacity: 0.5;  
		}
	// 50% {
	// 	transform: scale(1);  
	// 	// opacity: 0.5;  
	// }
	40%{
		transform: scale(1);
		opacity: 1; 
	}
		// 90% {
		// 	transform: scale(1);
		// 	opacity: 1; 
		// }
		100% {
			transform: scale(1);
			opacity: 1; 
		}
	}
	.TC {
		animation-name:tdtc;
		animation-duration:0.9s;
		transform-origin:350rpx 500rpx;
		animation-timing-function:cubic-bezier(0.01, 1.24, 0.08, 1.36);
		animation-iteration-count:1;
		animation-play-state: running;
		.toptext {
			position: absolute;
			// top: -8%;
			top: 100rpx;
			left: 35%;
			z-index: 999;
			background-color: #fff;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.text-a {

				font-size: 46rpx;
			}

			.text-b {
				color: rgb(148, 113, 254);
				font-size: 32rpx;
			}
		}

		height: 100%;
		background-color: rgb(255, 255, 255);

		// background: linear-gradient(#7a52c0, #d7d7d7) no-repeat;
		.title {
			text-align: center;
			line-height: 100rpx;
			font-size: 60rpx;
			color: rgb(164, 133, 237);
		}

		.box {
			z-index: 99;
			background-color: #fff;

			.box1 {

				// margin-top: 20rpx;
				.box1-a {
					width: 100%;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					height: 300px;
					align-items: center;

					image {
						width: 552rpx;
						height: 319rpx;
					}
				}
			}

			.send {
				position: absolute;
				right: 52rpx;

				uni-button {
					border-radius: 100rpx;
					height: 92rpx;
					line-height: 92rpx;
					color: #fff;
					width: 144rpx;
					background: rgb(121, 72, 234);
					font-size: 28rpx;
				}
			}

			.box2-a {
				width: 94%;
				height: 16px;
				background-color: #fffefe7d;
				box-shadow: 0px 5px 50px #9e9e9e3b;
				border-radius: 0rem 0rem 10px 10px;
				/* opacity: 0.4; */
				position: absolute;
				left: 3%;
				bottom: -16px;
				// /* z-index: -1;
			}

			.u-input--border[data-v-fdbb9fe6] {
				border-radius: 100rpx;
				height: 96rpx;
				box-sizing: border-box;
				padding-top: 8rpx !important;
				margin-left: 10rpx;
			}

			.username {
				font-size: 18px;
				display: flex;
				align-items: center;

				image {
					width: 16px;
					height: 16px;
					margin-right: 4px;
				}
			}

			.password {
				font-size: 18px;
				display: flex;
				align-items: center;
				margin-top: 30px;

				image {
					width: 16px;
					margin-right: 4px;
					height: 16px;
				}
			}

			.sms {
				display: flex;
				justify-content: end;
				color: rgb(164, 133, 237);
				padding: 10% 0;
				padding-bottom: 12%;
				margin-right: 36rpx;
			}

			z-index: 99;
			background-color: #fff;
			box-sizing: border-box;
			padding: 48rpx;
			box-shadow: 0px 10rpx 100rpx #9e9e9e80;
			position: absolute;
			background: #fff;
			width: 80%;
			height: 764rpx;
			border-radius: 2%;
			top: 228rpx;
			left: 10%;

			.btnA {

				width: 67%;
				margin: 0px auto;
				// margin-top: 40%;

				uni-button {
					border-radius: 64rpx;
					background: linear-gradient(to right, #A272FC, #DE62D2);
				}
			}

			.btnB {
				width: 60%;

				uni-button {
					margin-top: 20rpx;
					border-radius: 32px;
					color: #7a52c0;
				}

				margin: 0px auto;
			}
		}
	}


	.box {
		height: calc(100vh);
		width: 100%;
		background-image: url('@/static/icon/icon6/addaddress.png');
		background-position: 59% 73%;
		background-size: 123% 114%;
		position: relative;

		.address {
			.uni-input-placeholder {
				color: rgb(189, 189, 189);
			}

			.uni-textarea-placeholder {
				color: rgb(189, 189, 189);
			}

			button {
				border-radius: 66rpx;
				background: linear-gradient(to right, #A272FC, #DE62D2);
				color: #fff;
				line-height: 108rpx;
				height: 108rpx;
				font-size: 32rpx;
			}

			background-color: #fff;
			position: absolute;
			top: 16%;
			left: 5%;
			width: 90%;
			height: 916rpx;
			border-radius: 20rpx;
			box-shadow: 0px 10rpx 20rpx rgb(206, 206, 206) inset;
			box-sizing: border-box;
			padding: 68rpx 92rpx;

			.sh {
				display: flex;
				align-items: center;
				margin: 34rpx 0px;

				input {
					height: 96rpx;
					border: 2rpx solid rgb(121, 121, 121);
					border-radius: 80rpx;
					text-indent: 32rpx;
					width: 228rpx;
				}
			}

			.sh1 {
				display: flex;
				align-items: center;

				input {
					height: 96rpx;
					border: 2rpx solid rgb(121, 121, 121);
					border-radius: 80rpx;
					text-indent: 32rpx;
					width: 320rpx;
				}
			}

			.sh2 {
				display: flex;
				margin: 34rpx 0px;

				// align-items: center;
				textarea {
					height: 280rpx;
					border: 2rpx solid rgb(121, 121, 121);
					border-radius: 80rpx;
					text-indent: 40rpx;
					line-height: 80rpx;
					width: 320rpx;
				}
			}
		}
	}
</style>
